package com.zhou.exception;

import com.zhou.domain.Rusult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//注解声明这是异常处理器，要让spring配置扫到
//@RestControllerAdvice
public class ProjectExceptionAdvice {
    //设定捕获那种异常，并将返回值作为结果抛出
    @ExceptionHandler(Exception.class)
    public Rusult doException(Exception ex){
        System.out.println("捕获异常");
        //return 出现异常后返回给页面的数据
        return new Rusult(500,null,ex.getMessage());
    }
}